<template>
  <div class="user-card">
    <img class="vip-bg" src="@/assets/icon/user/vip-logo.png" alt="" />
    <div class="user-card-nei flex align-center">
      <img class="avatar-img" :src="userInfo.avatar" alt="" />
      <div class="info">
        <div class="names flex align-center">
          <div class="name">{{ userInfo.nickname }}</div>
          <div class="tag flex align-center">
            <img src="@/assets/icon/user/vip/zhuanshi.png" alt="" />
            <span>
              {{ userInfo.user_type === 'COMMENT' ? '普通用户' : 'VIP用户' }}
            </span>
          </div>
        </div>
        <div class="desc">
          <span v-if="userInfo.user_type === 'COMMENT'">
            你还未开通本站任何VIP，开通VIP会员，立享专属特权。
          </span>
          <!--          <template v-else-if="userInfo.overdueTime">-->
          <!--            <span v-if="isWithin30Days(userInfo.overdueTime)">-->
          <!--              你得VIP会员已到期，请尽快续费，享受超值特权。-->
          <!--            </span>-->
          <!--            <span v-else>到期日期: {{ userInfo.overdueTime }}</span>-->
          <!--          </template>-->
        </div>
      </div>
      <NButton class="opened-btn" type="primary" round @click="handVip">
        {{ userInfo.user_type === 'COMMENT' ? '开通VIP会员' : '续费VIP会员' }}
      </NButton>
    </div>
  </div>
  <vip-dia ref="vipRef" />
</template>
<script setup lang="ts">
import { NButton } from 'naive-ui'
import VipDia from '@/components/VipDia.vue'
import { ref } from 'vue'
import { useAppsStore } from '@/stores/modules/app'
import { storeToRefs } from 'pinia'
// import { isWithin30Days } from '@/utils'
const useStore = useAppsStore()
const { getUserInfo: userInfo } = storeToRefs(useStore)
const vipRef = ref()
const handVip = () => {
  vipRef.value.open()
}
</script>

<style scoped lang="scss">
.user-card {
  height: 166px;
  background: linear-gradient(94deg, #e7c4a4 0%, #db9f57 100%);
  border-radius: 12px;
  padding: 0 48px;
  position: relative;
  .vip-bg {
    position: absolute;
    z-index: 0;
    width: 204px;
    height: 166px;
    right: 236px;
  }
  &-nei {
    height: 100%;
    position: relative;
    z-index: 2;
  }

  .avatar-img {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    object-fit: cover;
  }
  .info {
    flex: 1;
    margin: 0 20px;
    .names {
      .name {
        font-size: 18px;
        font-weight: 400;
        color: #51443d;
      }
      .tag {
        margin-left: 8px;
        background: #d5af8a;
        border-radius: 5px;
        padding: 6px 11px;
        cursor: pointer;
        img {
          width: 18px;
          height: 18px;
          display: block;
        }
        span {
          margin-left: 4px;
          font-size: 14px;
          font-weight: 400;
          color: #51443d;
        }
      }
    }
    .desc {
      margin-top: 8px;
      font-size: 14px;
      font-weight: 400;
      color: #6c5c52;
    }
  }
  .opened-btn {
    width: 164px;
    height: 48px;
    font-size: 16px;
  }
}
</style>
